package cn.tedu.controller;

import cn.tedu.service.MenuService;
import cn.tedu.vo.SysUserMenu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class PageController {
    @Autowired
    private MenuService MenuService;

    @RequestMapping("/")
    public String showIndex(Model model){
        //查询用户对应的菜单信息(一级，二级)并存储到model，然后在页面上进行呈现。
        List<SysUserMenu> userMenus=
                MenuService.findUserMenusByUserId(1);
        model.addAttribute("userMenus", userMenus);
        return "starter";
    }
    @RequestMapping("doPageUI")
    public String doPageUI() {
        return "common/page";
    }
    @RequestMapping("doLogin")
    public String doLogin() {
        return "login";
    }
    @RequestMapping("/{module}/{page}")
    public String showPage(@PathVariable String module, @PathVariable String page){
        return "sys"+"/"+page;
    }
}
